package com.oms.module.common.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oms.module.admin.domain.entity.AdminEntity;
import com.oms.module.common.dao.MenuMapper;
import com.oms.module.common.domain.MenuEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author zhanghailong QQ38592077
 * @Description TODO
 * @Date 2020/6/11 14:34
 */
@Service
public class MenuService extends ServiceImpl<MenuMapper, MenuEntity> {
    @Autowired
    MenuMapper menuMapper;

    public List<MenuEntity> getMenus() {
        return menuMapper.getMenusById(((AdminEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }

    @Cacheable(cacheNames = "menu")
    public List<MenuEntity> selectAll() {
        return menuMapper.selectAll();
    }
}
